﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace JXT.PrimaryKey.Batman.Language
{
    /// <summary>
    /// 默认语言处理类
    /// </summary>
    public class DefaultLanguage : ILanguage
    {
        /// <summary>
        /// 获取所有转换器
        /// </summary>
        /// <param name="culture">区域属性</param>
        /// <returns>转换器列表</returns>
        public IEnumerable<Phrase> GetTranslations(CultureInfo culture)
        {
            return new List<Phrase>();
        }

        /// <summary>
        /// 获取个性化文字
        /// </summary>
        /// <param name="key">资源key</param>
        /// <param name="culture">语言区域信息</param>
        /// <returns>对应区域文字</returns>
        public string Localize(string key, CultureInfo culture)
        {
            return key;
        }

        /// <summary>
        /// 获取个性化区域文字
        /// </summary>
        /// <param name="key">资源key</param>
        /// <param name="defaultValue">默认值</param>
        /// <param name="culture">语言区域信息</param>
        /// <returns>对应区域文字</returns>
        public string Localize(string key, string defaultValue, CultureInfo culture)
        {
            return defaultValue;
        }

        /// <summary>
        /// 语言区域
        /// </summary>
        public CultureInfo Culture
        {
            get { return CultureInfo.CurrentCulture; }
        }

        /// <summary>
        /// 获取所有语言转换器
        /// </summary>
        /// <returns>语言转换器集合</returns>
        public IEnumerable<Phrase> GetTranslations()
        {
            return GetTranslations(Culture);
        }

        /// <summary>
        /// 本地化字符串
        /// </summary>
        /// <param name="key">语言key</param>
        /// <returns>转换结果</returns>
        public string Localize(string key)
        {
            return Localize(key, Culture);
        }

        /// <summary>
        /// 本地化字符串
        /// </summary>
        /// <param name="key">语言key</param>
        /// <param name="defaultValue">默认字符串</param>
        /// <returns>转换结果</returns>
        public string Localize(string key, string defaultValue)
        {
            return Localize(key, defaultValue, Culture);
        }
    }
}
